this._native.connect('new-request', this._newRequest.bind(this));
this._native.connect('cancel-request', this._cancelRequest.bind(this));
- try {
- this._native.init(null);
- } catch(e) {
- this._native = null;
- logError(e, 'error initializing the NetworkManager Agent');
- }
+
+ this._initialized = false;
+ this._native.init_async(GLib.PRIORITY_DEFAULT, null, (o, res) => {
+ try {
+ this._native.init_finish(res);
+ this._initialized = true;
+ } catch(e) {
+ this._native = null;
+ logError(e, 'error initializing the NetworkManager Agent');
+ }
+ });
},
enable() {
return;
this._native.auto_register = true;
- if (!this._native.registered)
+ if (this._initialized && !this._native.registered)
this._native.register_async(null, null);
},
return;
this._native.auto_register = false;
- if (this._native.registered)
+ if (this._initialized && this._native.registered)
this._native.unregister_async(null, null);
},